$currentDir = Get-Location
$dir = $env:windir + "\system32\inetsrv"

Set-Location $dir
$sites = .\appcmd.exe list config /section:system.applicationHost/sites /xml

$sitesXml = [xml] $sites;
$demoSiteBindingInformation = $sitesXml.SelectSingleNode("//site[@name='PHPTrainingKitDemos']//bindings//binding[@protocol='http']").getAttribute("bindingInformation");

if ($demoSiteBindingInformation -ne "")
{
	$demoPort = $demoSiteBindingInformation.SubString($demoSiteBindingInformation.IndexOf(":") + 1, $demoSiteBindingInformation.LastIndexOf(":") - 2);
	$demoUrl = "http://localhost:$demoPort/SpatialDemo/code/index.php";
	
	Write-Output "Opening $demoUrl...";
	
	$ie = new-object -Com internetexplorer.application;
	$ie.Navigate2($demoUrl);
	$ie.visible = $TRUE;
}
else
{
	Write-Error "Could not find PHPTrainingKitDemos web site on IIS";
}

Set-Location $currentDir;

